<?php

namespace app\system\model\customer;

use app\system\controller\product\Category;
use app\system\model\Admin;
use app\system\model\business\Quotation;
use app\system\model\corp\Agent;
use app\system\model\Customer;
use think\Model;


class OrderBill extends Model {
    /**
     * @var string 自动写入时间戳
     */
    protected $autoWriteTimestamp = false;

//    public $append = ['amount_text'];

    public $name = 'order_bill';

    public function getStatusAttr($value){
        return $value != '' && $value != null ? explode(',', $value) : [];
    }

    public function product(){
        return $this->hasOne(Product::class, 'id', 'product_id');
    }



    public function quotation(){
        return $this->hasMany(Quotation::class, 'business_id', 'id');
    }

    public function getamountTextAttr($value, $data){
        return number_format($data['amount']) . ' CNY';
    }

//    public function getFilesAttr($value){
//        return empty($value) ? [] : json_decode($value, true);
//    }

    public function getCreateDateTextAttr($value, $data){
        return date('Y-m-d', $data['create_time']);
    }

    public function getCreateTimeTextAttr($value, $data){
        return date('H:i:s', $data['create_time']);
    }


}